package com.xuhai.blog19.api;

import com.xuhai.blog19.admin.service.TimelineService;
import com.xuhai.blog19.common.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author PangJunjie
 * @Date 2023/2/11/011
 */
@RestController
@RequestMapping("/api")
public class ApiTimelineController {
    @Autowired
    private TimelineService timelineService;

    @GetMapping("/timeline")
    public R getTimeLine() {
        return R.ok().data(timelineService.getTimeline());
    }

    @GetMapping("/timeline/{year}")
    public R getArticleByYear(@PathVariable String year) {
        return R.ok().data(timelineService.getArticleByYear(year));
    }
}
